<%@ page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/base/taglibs.jsp"%>

<html>
	<head>
		<link href="${ctx}/css/main.css" rel="stylesheet" type="text/css" />
	</head>
	
	<script language="javascript">
		function submitAction(action){
			if(document.getElementById('contactor').value == '') {
				alert('请输入联系人');
				return false;
			}
			if(document.getElementById('mobileNumber').value == '' && document.getElementById('telNumber').value == '') {
				alert('手机号码和电话号码至少填一个');
				return false;
			}
			if(document.getElementById('email').value == '') {
				alert('请输入电子邮箱地址');
				return false;
			}
			if(!validateEmail()) return false;
			if(document.getElementById('companyAddress').value == '') {
				alert('请输入公司地址');
				return false;
			}
			document.contactInfoForm.action = action ;
			document.contactInfoForm.submit();
		}
		
		function validateEmail() {
			var emailpattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; 
		   	email = document.getElementById("email").value; 
			if(emailpattern.test(email) == false) {
				alert('电子邮箱栏位不是有效的电子邮箱地址格式，请重新输入');
				return false;
			}
			return true;
		}
	</script>
	
	<body>
	
	<form method="post" action="" name="contactInfoForm">
			<table border="0" cellspacing="1" cellpadding="3" align="center" width="100%">
				<tr>
					<td width="20%" class="td2"> 
						联系人 <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="60%" class="td2">
						<input type="text" name="contactor" size="30" value="${siteContactInfo.contactor}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						手机号码 <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="60%" class="td2">
						<input type="text" name="mobileNumber" size="30" value="${siteContactInfo.mobileNumber}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						电话号码 <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="60%" class="td2">
						<input type="text" name="telNumber" size="30" value="${siteContactInfo.telNumber}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						传真号码
					</td>
					<td width="60%" class="td2">
						<input type="text" name="fixNumber" size="30" value="${siteContactInfo.fixNumber}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						电子邮箱 <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="60%" class="td2">
						<input type="text" name="email" size="30" value="${siteContactInfo.email}" onblur="validateEmail();">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						QQ号码 
					</td>
					<td width="60%" class="td2">
						<input type="text" name="qq" size="30" value="${siteContactInfo.qq}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						公司地址 <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="60%" class="td2">
						<textarea rows="3" cols="70" name="companyAddress">${siteContactInfo.companyAddress}</textarea>
					</td>
				</tr>
				<tr>
					<td class="td11" align="left" colspan="4">
					    &nbsp;&nbsp;
						<input type="button" name="save" value="确认并保存" onClick="submitAction('siteContactInfoSave.ac');">
					</td>
				</tr>
			</table>
			<BR>
		</form>
	</body>
</html>